package com.zzty.txj1.dao;



import com.zzty.txj1.entity.Group;
import com.zzty.txj1.entity.Question;
import com.zzty.txj1.entity.TeamExam;
import com.zzty.txj1.entity.TeamExamTransaction;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TeanExamMapper {
    @Select("select * from question")
    public List<Question>getQuestion();

    @Select("select count(*) from question")
    public Integer getQuestionCount();



    @Insert("insert into question (content) values (#{content})")
    public Integer addQuestion(Question question);

    @Insert("insert into teamExam (questionId,date,clazzId)values (#{questionId},#{date},#{clazzId})")
    public Integer submitQuestion(TeamExam teamExam);

    @Insert("insert into groupp (userName1,userName2,clazzId) values (#{userName1} , #{userName2},#{clazzId})")
    public Integer addTeam(Group group);

    @Select("select * from groupp where clazzId=#{clazzId}")
    public List<Group>group(Group group);

    @Delete("delete  from groupp where id=#{id}")
    public Integer deleteGroup(Group group);

    @Select("select id from teamExam where classId=#{classId} and date=#{date}")
    public Integer getId(TeamExam teamExam);

    @Select("select groupId from teamExamTransaction where teamExamId=#{teamExamId}")
    public List<Integer> getGroupId(Integer id);

    @Select("select * from groupp where id=#{id}")
    public Group getGroupName(Integer id);

    @Select("select * from teamExamTransaction where teamExamId=#{teamExamId} and groupId=#{groupId}")
    public TeamExamTransaction getinfo(TeamExamTransaction teamExamTransaction);

    @Update("update teamExamTransaction set score=#{score} , comment=#{comment} where groupId=#{groupId} and teamExamId=#{teamExamId}")
    Integer updateTeamExamTransaction(TeamExamTransaction teamExamTransaction);

    @Select("select id from user where name=#{name}")
    Integer getUserId(String name);

    @Update("update teamExam set winnerId1=#{winnerId1} , winnerId2=#{winnerId2} where  id=#{id}")
    Integer updateTeamExam(TeamExam teamExam);
}
